package ru.ncedu.java.dmsi.robots.strategies.impl;

import ru.ncedu.java.dmsi.robots.actions.Action;
import ru.ncedu.java.dmsi.robots.actions.impl.MoveAction;
import ru.ncedu.java.dmsi.robots.model.*;
import ru.ncedu.java.dmsi.robots.strategies.RobotStrategy;

import java.util.Random;

public class RandomMoveStrategy implements RobotStrategy {
    public Action getAction(ActionContext context) {
        Random gen = new Random(System.currentTimeMillis());
        PointFactory pf = PointFactory.getInstance();
        Point oldP = context.getCurrentLocation();

        // It may be destroyed and it is funny
        return new MoveAction(pf.getPoint(oldP.getX() + gen.nextInt(2) - 1, oldP.getY() + gen.nextInt(2) - 1));
    }
}
